home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 245 / growaray.doc < prev    next >
Text File  |  1988-02-07  |  2KB  |  36 lines

  1.                           Growing Arrays
  2.                    a somewhat strange technique
  3.                            in GFA BASIC
  4.                            by DAEDWARDS
  5.  
  6.      Every now and then you need a really huge array,  but you are 
  7. not certain just how big.  This might occur in sorts,  or when you 
  8. are processing text. Or consider a spreadsheet.
  9.  
  10.      And there are tradeoffs - if you are processing a small  text 
  11. file,  you can really speed things up with a RAMdisk,  but if  the 
  12. file gets too big,  you need that memory for processing.  Or on  a 
  13. spreadsheet - some spreadsheets are 200 rows of 20 columns, others 
  14. are 20 rows of 200 columns. How do you dimension the array?
  15.  
  16.      There  are  all sorts of tricks to use to get  out  of  this, 
  17. involving dynamic memory allocation and pointers,  or doing a  lot 
  18. of extra calculation yourself,  but a way around it which I  think 
  19. is  unique to GFA Basic is to make the array grow in  the  desired 
  20. direction. Nothing changes except the size. It still has the same
  21. name,  you  don't need to mess with pointers,  and you  can  still 
  22. expect GFA Basic to do the work for you.
  23.  
  24.      There is a minor catch - if you want lots of different arrays 
  25. to  change  size (they can,  in theory,  shrink as well  as  grow, 
  26. although  I  have never needed to shrink one),  then  you  need  a 
  27. separate routine for each variable type (integer,  real,  boolean, 
  28. or string) at each number of dimensions. In other words, the array
  29. A$(X,Y), A$(X), and A(X) involve three different "grow" routines.
  30.  
  31.      The  GFA Basic program demonstrates the growth of  a  single-
  32. dimensioned  string  array  and  a  two-dimension  array  of  real 
  33. numbers.
  34.  
  35.  
  36.